<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page pageEncoding="UTF-8" %>
<%@taglib uri="http://wasf.cb.com/tag" prefix="wasf" %>
<wasf:useTemplate name="template/standard.jsp" title="User list">
    <wasf:defineFragment name="body">
        <c:if test="${state.users.countAll != 0}">
            <wasf:form id="usersForm">
                <c:if test="${state.users.fromIndex > 0}">
                    <wasf:submitLink event="prevPage">Prev page</wasf:submitLink>&nbsp;&nbsp;&nbsp;&nbsp;
                </c:if>
                <c:if test="${state.users.fromIndex + state.users.count < state.users.countAll}">
                    <wasf:submitLink event="nextPage">Next page</wasf:submitLink>
                </c:if>
                <table class="ui-widget">
                    <tr>
                        <th class="ui-widget-header" colspan="5" style="text-align: right"><wasf:submitLink event="createUser">Créer un nouvel utilisateur</wasf:submitLink></th>
                    </tr>
                    <tr>
                        <th class="ui-widget-header">Login</th>
                        <th class="ui-widget-header">Fisrt name</th>
                        <th class="ui-widget-header">Last name</th>
                        <th class="ui-widget-header">Mail</th>
                        <th class="ui-widget-header">Edit / delete</th>
                    </tr>
                    <c:forEach var="user" items="${state.users.list}">
                        <tr>
                            <td class="ui-widget-content"><c:out value="${user.login}"/></td>
                            <td class="ui-widget-content"><c:out value="${user.firstName}"/></td>
                            <td class="ui-widget-content"><c:out value="${user.lastName}"/></td>
                            <td class="ui-widget-content"><c:out value="${user.mail}"/></td>
                            <td class="ui-widget-content" style="text-align: right"><wasf:submitLink event="editUser" id="${user.id}">E</wasf:submitLink>&nbsp;&nbsp;&nbsp;&nbsp;<wasf:submitLink event="deleteUser" id="${user.id}">X</wasf:submitLink></td>
                            </tr>
                    </c:forEach>
                </table>
            </wasf:form>
        </c:if>
        <c:if test="${state.users.countAll == 0}">
            No user found
        </c:if>
    </wasf:defineFragment>
</wasf:useTemplate>